Skip to content

fix examples to follow options.h config#10037

Merged
douzzer merged 4 commits intowolfSSL:masterfrom
JacobBarthelmeh:nightly
Apr 2, 2026
Merged

fix examples to follow options.h config#10037
douzzer merged 4 commits intowolfSSL:masterfrom
JacobBarthelmeh:nightly

Conversation

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor

The example server/client should not be modifying macro defines that come from how the wolfSSL library is configured when built.

Copy link
Copy Markdown

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10037

No scan targets match the changed files in this PR. Review skipped.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the example client/server (and shared test helpers) to stop overriding build-time configuration macros (from options.h / settings.h) and instead compile cleanly against the wolfSSL API surface as configured.

Changes:

  • Removed example-level #undef/forced-define blocks related to OPENSSL_COEXIST and OpenSSL-compat headers.
  • Migrated examples/server/server.c off OpenSSL-compat SSL_* names to WOLFSSL* / wolfSSL_* APIs.
  • Added !OPENSSL_COEXIST preprocessor guards around OpenSSL-extra-only printing paths in wolfssl/test.h.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
wolfssl/test.h Avoids OpenSSL-extra helper paths when OPENSSL_COEXIST is set.
examples/server/server.c Switches example server from SSL_* APIs/types to wolfSSL_*/WOLFSSL_*.
examples/client/client.c Stops undefining coexist macros; aligns buffer filetype constants with wolfSSL API.
Comments suppressed due to low confidence (4)

examples/server/server.c:640

  • In ServerWrite(), after wolfSSL_write() returns <= 0, the code calls wolfSSL_get_error(ssl, 0). wolfSSL_get_error() should be given the return value from the preceding call, otherwise the async/WANT_WRITE loop can behave incorrectly. Use wolfSSL_get_error(ssl, ret) here.
    do {
        err = 0; /* reset error */
        ret = wolfSSL_write(ssl, output, len);
        if (ret <= 0) {
            err = wolfSSL_get_error(ssl, 0);

        #ifdef WOLFSSL_ASYNC_CRYPT
            if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
                ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);

examples/server/server.c:3665

  • In the early-data loop, when wolfSSL_read_early_data() returns <= 0, the code calls wolfSSL_get_error(ssl, 0) instead of passing the ret value from wolfSSL_read_early_data(). This can misreport WC_PENDING_E/WANT_READ/WANT_WRITE and break the loop logic. Pass ret to wolfSSL_get_error() here.
                    ret = wolfSSL_read_early_data(ssl, input, sizeof(input)-1,
                                                                          &len);
                    if (ret <= 0) {
                        err = wolfSSL_get_error(ssl, 0);
                    #ifdef WOLFSSL_ASYNC_CRYPT
                        if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
                            /* returns the number of polled items or <0 for
                             * error */
                            ret = wolfSSL_AsyncPoll(ssl,
                                                    WOLF_POLL_FLAG_CHECK_HW);
                            if (ret < 0) break;
                        }

examples/server/server.c:456

  • In ServerEchoData(), when wolfSSL_read() returns <= 0, the code calls wolfSSL_get_error(ssl, 0) instead of passing the ret value from wolfSSL_read(). This can produce an incorrect error code and break the WANT_READ/WANT_WRITE handling. Pass ret to wolfSSL_get_error() here.
            /* Read data */
            while (rx_pos < len) {
                ret = wolfSSL_read(ssl, &buffer[rx_pos], len - rx_pos);
                if (ret <= 0) {
                    err = wolfSSL_get_error(ssl, 0);
                #ifdef WOLFSSL_ASYNC_CRYPT
                    if (err == WC_NO_ERR_TRACE(WC_PENDING_E)) {
                        ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW);
                        if (ret < 0) break;

examples/server/server.c:492

  • In ServerEchoData(), the write error path logs err when wolfSSL_write() returns a short write, but err is not set based on the write result (and may still be uninitialized if the preceding reads succeeded). Capture the error from the write call (e.g., via wolfSSL_get_error(ssl, ret) when ret <= 0, or set a deterministic value for short writes) before logging/handling it.
            WOLFSSL_ASYNC_WHILE_PENDING(
                  ret = wolfSSL_write(ssl, buffer, (int)min((word32)len, (word32)rx_pos)),
                  ret <= 0);
            if (ret != (int)min((word32)len, (word32)rx_pos)) {
                LOG_ERROR("SSL_write echo error %d\n", err);
                err_sys_ex(runWithErrors, "SSL_write failed");
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JacobBarthelmeh
Copy link
Copy Markdown
Contributor Author

JacobBarthelmeh commented Mar 25, 2026

Retest this please Jenkins

@JacobBarthelmeh JacobBarthelmeh added the For This Release Release version 5.9.1 label Mar 30, 2026
@douzzer douzzer added Staged Staged for merge pending final test results and review and removed Staged Staged for merge pending final test results and review labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs fixes -- I think just WOLFSSL_BIO_NOCLOSE instead of BIO_NOCLOSE:

[all-crypto-openssl-extra-coexist-smallstack] [16 of 61] [4f295cfb83]
    configure${config_analyzer_note}...   real 0m12.179s  user 0m7.235s  sys 0m5.970s
    build...examples/client/client.c: In function ‘client_test’:
2dafd2102c (<carie@wolfssl.com> 2019-09-19 18:11:10 -0600 4381)         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
examples/client/client.c:4381:55: error: ‘BIO_NOCLOSE’ undeclared (first use in this function)
 4381 |         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
      |                                                       ^~~~~~~~~~~
2dafd2102c (<carie@wolfssl.com> 2019-09-19 18:11:10 -0600 4381)         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
examples/client/client.c:4381:55: note: each undeclared identifier is reported only once for each function it appears in
examples/client/client.c: In function ‘client_test’:
2dafd2102c (<carie@wolfssl.com> 2019-09-19 18:11:10 -0600 4381)         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
examples/client/client.c:4381:55: error: ‘BIO_NOCLOSE’ undeclared (first use in this function)
 4381 |         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
      |                                                       ^~~~~~~~~~~
2dafd2102c (<carie@wolfssl.com> 2019-09-19 18:11:10 -0600 4381)         WOLFSSL_BIO* bio = wolfSSL_BIO_new_fp(stdout, BIO_NOCLOSE);
examples/client/client.c:4381:55: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [Makefile:11200: examples/client/testsuite_testsuite_test-client.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [Makefile:10024: examples/client/tests_unit_test-client.o] Error 1
make[1]: *** [Makefile:11465: all-recursive] Error 1
make: *** [Makefile:6282: all] Error 2
   real 0m5.647s  user 0m28.594s  sys 0m1.509s
    scenario started 2026-03-30T23:36:07.364225Z, real elapsed 0m17.893915s
    all-crypto-openssl-extra-coexist-smallstack fail_build
    failed config: 'EXTRA_CPPFLAGS=-Werror' '--srcdir' '.' '--disable-jobserver' '--enable-option-checking=fatal' '--enable-all' '--enable-acert' '--enable-dtls13' '--enable-dtls-mtu' '--enable-dtls-frag-ch' '--enable-dtlscid' '--enable-quic' '--with-sys-crypto-policy' '--enable-experimental' '--enable-kyber=yes,original' '--enable-lms' '--enable-xmss' '--enable-dilithium' '--enable-slhdsa' '--enable-dual-alg-certs' '--disable-qt' '--disable-opensslall' '--enable-opensslcoexist' '--disable-all-osp' '--enable-wpas' '--disable-quic' '--enable-smallstack' '--enable-smallstackcache' 'CFLAGS=-DTEST_ALWAYS_RUN_TO_END -DOPENSSL_COMPATIBLE_DEFAULTS' 'CPPFLAGS=-DNO_WOLFSSL_CIPHER_SUITE_TEST -DWOLFSSL_OLD_PRIME_CHECK -pedantic -Wdeclaration-after-statement -Wnull-dereference -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE'

Copilot AI review requested due to automatic review settings March 31, 2026 19:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@douzzer douzzer added the Staged Staged for merge pending final test results and review label Apr 1, 2026
@douzzer douzzer merged commit 3c87500 into wolfSSL:master Apr 2, 2026
504 of 506 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.1 Staged Staged for merge pending final test results and review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants